<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::namespace('Common')->prefix('common')->group(function () {
    //发送验证码
    Route::post('sms/sendCode', 'VerifyCodeController@postSendCode');

    //上传图片
    Route::post('upload/image', 'UploadController@uploadImg');

    // 车辆品牌列表
    Route::get('brand/list', 'ListController@getBrand');
    // 车辆列表
    Route::get('car/list', 'ListController@getCar');
    // 司机列表
    Route::get('driver/list', 'ListController@getDriver');
    // 管理员公司列表
    Route::get('company/list', 'ListController@getCompany');
    // 驾照类型列表
    Route::get('licence/list', 'ListController@getLicence');
    // 业务类型列表
    Route::get('service/list', 'ListController@getService');
    // 地区列表
    Route::get('region/list', 'ListController@getRegion');



});

Route::get('driver/export', 'Api\\Driver\\DriverController@carExcel');//导出司机
Route::get('driver/carExcels', 'Api\\Driver\\DriverController@carExcels');//导出代驾司机
Route::get('withdraw/export', 'Api\\Finance\\WithdrawController@WithdrawExcel');//导出提现
Route::get('order/export', 'Api\\Orders\\OrderController@orderExcel');//订单导出
Route::get('finance/export', 'Api\\Finance\\FinancialFlowController@driverExcel');//乘客流水导出
Route::namespace('Api')->group(function () {
    Route::post('login', 'LoginController@login');

    /**
     * 司机
     */
    Route::namespace('Driver')->group(function () {
        // 司机管理
        Route::prefix('driver')->group(function () {
            Route::get('list', 'DriverController@getPageList');
            Route::get('info', 'DriverController@getFirst');
            Route::post('save', 'DriverController@save');
            Route::post('delete', 'DriverController@delete');
            Route::post('state/save', 'DriverController@saveState');
            Route::post('password/save', 'DriverController@savePassword');

            Route::post('taxi/save', 'DriverController@save_edit');

            //代驾

            Route::get('driving/list', 'DriverController@getList');
            Route::post('driving/save', 'DriverController@edit');
            Route::post('driving/save_status', 'DriverController@saves');
            Route::post('driving/details', 'DriverController@details');
        });


        // 车辆管理
        Route::prefix('car')->group(function () {
            Route::get('list', 'CarController@getPageList');
            Route::get('info', 'CarController@getFirst');
            Route::post('save', 'CarController@save');
            Route::post('delete', 'CarController@delete');
            Route::post('state/save', 'CarController@saveState');
            Route::post('driver', 'CarController@driver');//导入司机
            Route::post('driving', 'CarController@drivers');//导入代驾司机

        });

        // 评论
        Route::prefix('comment')->group(function () {
            Route::get('list', 'CommentController@getPageList');
        });

    });


    /**
     * 财务
     */
    Route::namespace('Finance')->group(function () {
        // 流水明细
        Route::prefix('finance')->group(function () {
            Route::get('list', 'FinancialFlowController@getPageList');
            Route::get('driver', 'FinancialFlowController@driver');//乘客流水明细
            Route::get('info', 'FinancialFlowController@info');  //流水分页及查询
        });

        // 司机提现
        Route::prefix('withdraw')->group(function () {
            Route::get('list', 'WithdrawController@getPageList');
            Route::post('save', 'WithdrawController@save');
        });

    });

    /**
     * 乘客
     */
    Route::namespace('Passenger')->middleware('auth:api')->group(function () {
        // 所有乘客
        Route::prefix('user')->group(function () {
            Route::get('list', 'UserController@getPageList');
            Route::get('info', 'UserController@getFirst');
            Route::post('save', 'UserController@save');
            Route::post('delete', 'UserController@delete');
        });
        //优惠券
        Route::prefix('coupon')->group(function () {
            Route::get('list', 'CouponController@getList'); //列表
            Route::post('collect_coupons', 'CouponController@collect_coupons'); //列表

        });
        //用户充值流水
        Route::prefix('recharge')->group(function () {
            Route::post('list', 'RechargeController@lists'); //列表
            Route::post('invest', 'RechargeController@invest'); //用户充值

        });

    });

    /**
     * 资费
     */
    Route::namespace('Expenses')->middleware('auth:api')->prefix('tariff')->group(function () {
        Route::get('list', 'TariffController@getPageList');
        Route::get('info', 'TariffController@getFirst');
        Route::post('save', 'TariffController@save');
        Route::post('delete', 'TariffController@delete');
        //代驾资费
        Route::get( 'driving_tariff/list', 'DrivingTariffController@getPageList');
        Route::get( 'driving_tariff/info', 'DrivingTariffController@getFirst');
        Route::post('driving_tariff/save', 'DrivingTariffController@save');
        Route::post('driving_tariff/delete', 'DrivingTariffController@delete');
    });


    /**
     * 订单
     */
    Route::namespace('Orders')->group(function () {
        // 快车订单
        Route::prefix('order')->group(function (){
            Route::get('list', 'OrderController@getPageList');
            Route::get('info', 'OrderController@getFirst');
            Route::post('save', 'OrderController@save');
        });
    });


});
/**
 * 司机端app
 */
Route::namespace('DriverApp')->prefix('driver_app')->group(function () {
    //注册
    Route::post('logins', 'LoginController@login');//登录
    Route::post('reg', 'LoginController@regerster'); //注册
    Route::post('informations', 'DriveregController@information'); //设置密码
});
Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});
